#include "../frame.hpp"

const char* title() { return "NVG OpenGL3.3"; }
void handleEvent(sdl::event::Event &evt) {}
void render(NVGcontext *nvg) {
  nvg::Canvas cvs(nvg);

  glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  float x = WND_WIDTH / 2.f;
  float y = WND_HEIGHT / 2.f;

  // color
  auto strokeColor = nvg::Color::fromRGBA(1.f, 0.f, 1.f);
  auto fillPaint = cvs->linearGradient(0.f, 0.f, WND_WIDTH, WND_HEIGHT
      , nvg::Color::fromRGBA(1.0f, 1.f, 0.f)
      , nvg::Color::fromRGBA(1.f, 0.f, 1.f));

  // shape
  auto path = cvs->beginPath();
  path->circle(x, y, 100.f);
  path->roundedRect(x - 20.f, y - 20.f, 40.f, 40.f, 10.f);
  path->winding(nvg::Winding::Hole);

  // draw
  cvs->beginFrame(WND_WIDTH, WND_HEIGHT, 1.f);
  
  // fill
  cvs->fillPaint(fillPaint);
  cvs->fill();

  // stroke
  cvs->strokeColor(strokeColor);
  cvs->strokeWidth(2.f);
  cvs->stroke();

  cvs->endFrame();
}